package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

@SuppressWarnings("serial")
public class PanelEditGroup extends JPanel {

	private static PanelEditGroup single;

	private JTextField JTname = new JTextField();
	private JTextField JTid = new JTextField();

	private JButton add = new JButton("Opslaan");
	private JButton cancel = new JButton("Annuleren");

	private JLabel JLname = new JLabel("Naam klas:");

	private PanelEditGroup() {
		setLayout(null);
		setBounds(0, 0, 860, 720);

		add(PanelSelector.addTitle("Wijzig:"));

		JTname.setBounds(400, 150, 140, 30);
		JLname.setBounds(260, 150, 140, 30);
		add.setBounds(200, 500, 140, 30);

		cancel.setBounds(500, 500, 140, 30);

		cancel.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				PanelHolder mf = PanelHolder.getInstance();
				mf.remove(PanelEditGroup.getInstance());
				mf.add(PanelGroupList.getInstance());
				mf.repaint();
				mf.validate();
			}
		});

		add(JLname);
		add(JTname);
		add(add);
		add(cancel);
		JLname.setText(JTname.getText());
	}

	public Object getActionField() {

		return null;
	}

	public JTextField getJTname() {
		return JTname;
	}

	public void setJTname(JTextField jTname) {
		JTname = jTname;
	}

	public static PanelEditGroup getInstance() {
		if (single == null) {
			single = new PanelEditGroup();
		}
		return single;
	}

	public void selfDestroy() {
		single = null;
	}

	public static PanelEditGroup getSingle() {
		return single;
	}

	public static void setSingle(PanelEditGroup single) {
		PanelEditGroup.single = single;
	}

	public JButton getAdd() {
		return add;
	}

	public void setAdd(JButton add) {
		this.add = add;
	}

	public JButton getCancel() {
		return cancel;
	}

	public void setCancel(JButton cancel) {
		this.cancel = cancel;
	}

	public JLabel getJLname() {
		return JLname;
	}

	public void setJLname(JLabel jLname) {
		JLname = jLname;
	}

	public JTextField getJTid() {
		return JTid;
	}

}
